<?php

namespace api\system\controller;

class AdminCronController extends \Aaa\system\controller\AdminCronController {

    public $cc='xcxx';

    protected function init() {
        $path = CMF_ROOT . 'api/system/cron/';
        $files = glob($path . '*.php');
        $nameOptions = [];
        foreach ($files as $k => $v) {
            $name = substr(basename($v), 0, -4);
            $nameOptions[] = ['name' => $name, 'value' => $name];
        }

        $this->baseField = [
            [
                'field' => 'id',
                'name' => 'ID',
            ],
            [
                'field' => 'title',
                'name' => '名称',
            ],
            [
                'field' => 'name',
                'name' => '文件名',
                'type' => 'select',
                'options' => $nameOptions,
            ],
            [
                'field' => 'schedule',
                'name' => '	时间表',
            ],
            [
                'field' => 'last_time',
                'name' => '上次运行',
                'type' => 'time',
            ],
            [
                'field' => 'next_time',
                'name' => '下次运行',
                'type' => 'time',
            ],
            [
                'field' => 'status',
                'name' => '状态',
                'type' => 'radio',
                'options' => [
                    ['name' => '正常', 'value' => 0],
                    ['name' => '禁用', 'value' => 1],
                ],
                'default' => 0
            ],
            [
                'field' => 'remark',
                'name' => '说明',
            ],
        ];
    }

    protected function beforeIndex() {
        $this->actionField = ['id', 'title', 'name', 'schedule', 'last_time', 'next_time', 'status', 'remark'];
    }

    protected function beforeAdd() {
        $this->actionField = ['title', 'name', 'status', 'remark'];
    }

    protected function beforeEdit() {
        $this->actionField = ['title', 'name', 'status', 'remark'];
    }
}
